﻿CREATE proc [dbo].[NKNH_Them_L] 
--NKNH_Them_L '121122','','','','','','','','','','','','','','','','',''
--select*from nknh_l
--select *from nknh_h
@NHID bigint,
@tk nvarchar(255),
@chitiet_tk nvarchar(255),
@sotien float,
@ngoaite float,
@noidung nvarchar(255) ,
@tenhhdv nvarchar(255),
@ghichu nvarchar(255),
@tle_vat float,

@loai nvarchar(255),

@masothue nvarchar(255),
@so_seri nvarchar(255),
@tenkh nvarchar(255),
@malctte nvarchar(255),
@so_hdon nvarchar(255)
as

--select*from NKNH_L
	if not  exists(select * from NKNH_L  Where NHID=@NHID )
  begin
  select ErrCode=0 
  end 
  else
  begin
  Insert into NKNH_L(NHID,tk,chitiet_tk ,so_tien ,
					ngoaite ,noi_dung  ,
					tenhhdv,ghichu ,tle_vat,
					tien_vat ,loai ,nt_vat ,
					masothue ,so_seri ,tenkh,
					malctte ,so_hdon) 
					values(@NHID,@tk,@chitiet_tk ,@sotien ,
					@ngoaite ,@noidung  ,
					@tenhhdv,@ghichu ,@tle_vat,
					@sotien*@tle_vat/100 ,@loai ,@ngoaite*@tle_vat/100 ,
					@masothue ,@so_seri ,@tenkh,
					@malctte ,@so_hdon)
	
	select ErrCode=1 			
  end 
